# p41 第一题  键盘输入三个数，计算三角形面积
# import math
#
# san_line = input("请输入三边用空格分隔：").split()
# num = list(map(int, san_line))
# if num[0] + num[1] > num[2] and num[1] + num[2] > num[0] and num[0] + num[2] > num[1]:
#     p = 1 / 2 * sum(num)
#     print("p为：", p)
#     s = math.sqrt(p * (p - num[0]) * (p - num[1]) * (p - num[2]))
#     print("三角形面积为：", round(s, 2))
# else:
#     print("不是三角形")

# #test
# # 请输入三边用空格分隔：4 5 3
# # p为： 6.0
# # 三角形面积为： 6.0
# # 请输入三边用空格分隔：3 3 7
# # 不是三角形

# p41 第二题 成绩大于等于90用A 60-89用B 60以下用C
# score = int(input("请输入成绩："))
# if score >= 90 and score <= 100:
#     print("A")
# elif score <= 89 and score >= 60:
#     print("B")
# elif score < 60 and score >= 0:
#     print("C")
# else:
#     print("输入成绩有误")
#
# # text
# # 请输入成绩：90
# # A
# # 请输入成绩：89
# # B
# # 请输入成绩：60
# # B
# # 请输入成绩：59
# # C
# # 请输入成绩：101
# # 输入成绩有误
# # 请输入成绩：-1
# # 输入成绩有误

# p41 第三题 判断输入的一个整数能否同时被3和7整除，若输出Yes否输出No
# number = int(input("请输入数："))
# if number % 3 == 0 and number % 7 == 0:
#     print("Yes")
# else:
#     print("No")
# # test
# # 请输入数：21
# # Yes
# # 请输入数：42
# # Yes
# # 请输入数：14
# # No
# # 请输入数：9
# # No

# p41 第四题 根据输入的年份（4位数），判断是否为闰年
# number = int(input("请输入数四位数："))
# if number % 4 == 0 and number % 100 != 0 or number % 400 == 0:
#     print("Yes,闰年")
# else:
#     print("No,平年")
# # text
# # 请输入数四位数：3000
# # No,平年
# # 请输入数四位数：2000
# # Yes,闰年

# p41 第5题 出租车计费 输出车费保留1位 起步价10元3km 超过1.2/km 超过10km 1.5/km
# number = float(input("请输入里程："))
# mony = 0
# if number > 0 and number <= 3:
#     mony = 10
# elif number > 3 and number <= 10:
#     mony = 10 + (number - 3) * 1.2
# elif number > 10:
#     mony = 10 + 7 * 1.2 + (number - 10) * 1.5
# else:
#    print("数据有误")
# print("车费为：", round(mony,1))
#
# # text
# # 请输入里程：1
# # 车费为： 10
# # 请输入里程：3
# # 车费为： 10
# # 请输入里程：3.1
# # 车费为： 10.1
# # 请输入里程：11.5
# # 车费为： 20.6
# # 请输入里程：-1
# # 数据有误
# # 车费为： 0

# 第六题  输出1-100奇数
# print(list(range(2, 101, 2)))
# [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]

# 第七题 逆序输出
# number = list(input("请输入里程："))
# print(list(reversed(number)))
# # 请输入里程：12345678
# # ['8', '7', '6', '5', '4', '3', '2', '1']

# 第八题  1，2，3，4中三位数的排列组合
# import itertools
# numbers = [1, 2, 3, 4]
# permutations = itertools.permutations(numbers, 3)  # 生成所有r个元素的排列
# print(list(int(''.join(map(str, perm))) for perm in permutations))
# [123, 124, 132, 134, 142, 143, 213, 214, 231, 234, 241, 243, 312, 314, 321, 324, 341, 342, 412, 413, 421, 423, 431, 432]

# 第九题  20项阶乘和
# factorialSum = 0
# for i in range(1,21):
#     factorial = 1
#     for j in range(1,i+1):
#         factorial *= j
#     factorialSum += factorial
# print(factorialSum)
# 2561327494111820313

# 第10题  求斐波那契数列的分数形式之和
# molecule = 2
# denominator = 1
# sumSeries = 0
# for i in range(21):
#     item = molecule / denominator
#     sumSeries += item
#     print(i,item)
#     molecule_one = molecule + denominator
#     denominator_one = molecule
#     molecule, denominator = molecule_one, denominator_one
# print(sumSeries)
# 34.278294788817234

# 第11题  钻石图形
# def cyclelist(number):
#     odd_number_list = [i for i in range(numberlist + 1) if i % 2 == 1]
#     # deal_number_list =odd_number_list
#     deal_number_list = list(odd_number_list)
#     deal_number_list.reverse()  # 翻转
#     del deal_number_list[0]
#     cycle_number = odd_number_list + deal_number_list  # 拼接
#     return cycle_number


'''
一直出现bug的原因，该种赋值方法只是创建一个列表的引用，并没有直接创建列表
所以倒置和删除任然是在源列表操作
new_list = original_list这种方式只是创建了一个指向原列表的引用
new_list = list(original_list)  创建新的列表
new_list = copy.copy(original_list)copy.copy()执行的是浅拷贝，它足以处理不包含可变对象
new_list = copy.deepcopy(original_list)  完全独立地复制一个列表，包括其所有子列表和其他可变对象
'''


# def blanklist(numberlist):
#     number = (numberlist + 1) // 2
#     blanklist = [i for i in range(number)]
#     blanklistone = list(blanklist)
#     del blanklistone[0]
#     blanklistone.reverse()
#     blanklist = blanklistone + blanklist
#     return blanklist


# numberlist = int(input("输入一个奇数："))
# cycle_number = cyclelist(numberlist)
# blanklist = blanklist(numberlist)
# print(cycle_number)
# print(blanklist)

# 方法2
# rows = int(input('请输入菱形边长：\n'))
# row = 1
# while row <= rows:
#     col = 1
#     while col <= (rows - row):
#         print(' ', end='')  #打印空格
#         col += 2  #每次少打印两个空格
#     print(row * '*')
#     row += 2
#
# bottom = rows - 2  #递减部分少两个空格开始
# while bottom > 0:
#     col = 1
#     while bottom + col <= rows:
#         print(' ', end='')
#         col += 2
#     print(bottom * '*')
#     bottom -= 2

# 请输入菱形边长：
# 9
#     *
#    ***
#   *****
#  *******
# *********
#  *******
#   *****
#    ***
#     *

# #第十二题 九九乘法表
# for i in range(1, 10):
#     for j in range(1, i + 1):
#         print("{}x{}={}\t".format(j, i, i * j), end="")
#     print()
# 1x1=1
# 1x2=2	2x2=4
# 1x3=3	2x3=6	3x3=9
# 1x4=4	2x4=8	3x4=12	4x4=16
# 1x5=5	2x5=10	3x5=15	4x5=20	5x5=25
# 1x6=6	2x6=12	3x6=18	4x6=24	5x6=30	6x6=36
# 1x7=7	2x7=14	3x7=21	4x7=28	5x7=35	6x7=42	7x7=49
# 1x8=8	2x8=16	3x8=24	4x8=32	5x8=40	6x8=48	7x8=56	8x8=64
# 1x9=9	2x9=18	3x9=27	4x9=36	5x9=45	6x9=54	7x9=63	8x9=72	9x9=81

# #第十三题 斐波那契数列
# molecule = 2
# denominator = 1
# sumSeries = 0
# for i in range(21):
#     print(molecule,end=',')
#     molecule_one = molecule + denominator
#     denominator_one = molecule
#     molecule, denominator = molecule_one, denominator_one
# 2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,

# # 第十四题 100~1000水仙花数
# def flowerSum(num):
#     numStr = str(num)
#     n = len(numStr)  #数值长度
#     sum_of_powers = sum(int(digit)** n for digit in numStr)  #转换为字符串求和
#     return sum_of_powers == num
# for num in range(100,1001):
#     if flowerSum(num):
#         print(num)
# 153
# 370
# 371
# 407


# # 第十五题
# sum = 0
# base = int(input("输入基数："))
# numbers = int(input("输入个数："))
# count = base
# for i in range(numbers):
#     print(i, count)
#     sum += count
#     count = count * 10
#     count = count + base
# print("和为", sum)

# 输入基数：6
# 输入个数：5
# 0 6
# 1 66
# 2 666
# 3 6666
# 4 66666
# 和为 74070
